package cn.wind.xboot.conf.config;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * <p>Title: StartInfo</p>
 * <p>Description: TODO</p>
 *
 * @author xukk
 * @version 1.0
 * @date 2018/7/16
 */
@Component
@Slf4j
@Data
public class StartInfoRunner implements ApplicationListener<WebServerInitializedEvent> {
    public static int port;
    @Override
    public void onApplicationEvent(WebServerInitializedEvent webServerInitializedEvent) {
            port=   webServerInitializedEvent.getWebServer().getPort();
            log.warn("{} start successfully,the port is:{}",
                    webServerInitializedEvent.getApplicationContext().getEnvironment().getProperty("spring.application.name"),
                    webServerInitializedEvent.getWebServer().getPort());

    }
}
